function supportsRGBA()
{
	if(!('result' in arguments.callee))
	{
		var scriptElement = document.getElementsByTagName('script')[0];
		var prevColor = scriptElement.style.color;
		var testColor = 'rgba(0, 0, 0, 0.5)';
		if(prevColor == testColor)
		{
			arguments.callee.result = true;
		}
		else
		{
			try {
				scriptElement.style.color = testColor;
			} catch(e) {}
			arguments.callee.result = scriptElement.style.color != prevColor;
			scriptElement.style.color = prevColor;
		}
	}
	return arguments.callee.result;
}

(function($){

 	$.fn.extend({

		//pass the options variable to the function
 		cookieNotice: function(options) {


			//Set the default values, use comma to separate the settings, example:
			var defaults = {
				title: 'Test Title',
				subtitle: 'We use cookies but they\'re harmless.  Follow the link to read more',
				url: '#',
				linkText: ' - Cookie Policy &raquo;',
				css: {
					background:'#000000',
					borderTop:'1px solid #cdcbcb',
					borderRadius:'0px 0px 0px 0px',
					position:'fixed',
					color:'#C4C3C6',
					lineHeight: '20px',
					bottom:'0px',
					padding:'10px 0px',
					width: '100%',
					fontFamily: 'Arial, sans-serif',
					boxShadow: '2px 2px 8px #dcdcdc',
					zIndex:'10000'
				},
				rgbaback : 'rgba(0, 0, 0, 0.90)',
				delay: 500		
			};
			
			if(supportsRGBA()){
				defaults.css.background = defaults.rgbaback;
			}

			var options =  $.extend(defaults, options);
			
			$.extend(defaults, options);
			options.css.left = "0px";
			
			if($.cookie("cookieNoticeDisplayed2")){
				return;
			}
			
			
			//whatever shizzles here
			$('body').append('<div id="cookieNotice"><div id="cookieNoticeInner"><div id="cookieNoticeHide">Hide Message</div><div id="cookieNoticeTitle">'+options.title+'</div><div><div id="cookieNoticeSubTitle">'+options.subtitle+'<span id="cookieNoticeLink"><a href="'+options.url+'">'+options.linkText+'</a></span></div></div></div>');
			$('#cookieNotice').css(options.css);
				
			$('#cookieNoticeInner').css({
				width:	'920px',
				padding: '0px 20px',
				margin: 'auto'
			});
			
					
			$('#cookieNoticeTitle').css({
				fontSize: '18px',
				fontWeight:	'bold'
			});
			
			$('#cookieNoticeSubTitle').css({
				fontSize: '16px',
				padding: '5px 0px'
			});
			
			$('#cookieNoticeLink').css({
				fontSize: '16px',
				lineHeight: '24px'
			});
			
			$('#cookieNoticeLink a').css({
				fontSize: '15px',
				color: '#E6AF8A',
				textDecoration: 'none'
			}).attr('target','_blank');
			
			$('#cookieNoticeHide').css({
				background:'#038819',
				color:	'#f1ecec',
				'float': 'right',
				fontSize: '18px',
				borderRadius:'6px',
				padding: '0px 10px',
				lineHeight: '34px',
				cursor: 'pointer'
			});
			
			$('#cookieNoticeHide').mouseenter(function(){
				$(this).css({background:'#16BF33'});
			});
			
			$('#cookieNoticeHide').mouseleave(function(){
				$(this).css({background:'#038819'});
			});
			
			$('#cookieNoticeHide').click(function(){
				$.cookie("cookieNoticeDisplayed2",'true',{expires: 28, path: '/' });
				$('#cookieNotice').remove();
			});
			
			
			
			$('<style>@media(max-width:1024px){#cookieNoticeInner{width:100%!important;position:relative!important;padding:0!important}#cookieNoticeInner div{margin:0 175px 0 20px}#cookieNoticeInner #cookieNoticeHide{position:absolute!important;top:10px!important;right:20px!important;margin:0!important}#cookieNoticeInner #cookieNoticeSubTitle{margin:0}}@media(max-width:480px){#cookieNotice{zoom:.7}#cookieNoticeInner div{margin:0 20px}#cookieNoticeInner #cookieNoticeHide{position:static!important;float:none!important;width:120px;margin:0 auto 10px auto!important}#cookieNotice{padding-bottom:0!important}#cookieNoticeInner #cookieNoticeHide{font-size:12px!important;line-height:24px!important;float:none!important;width:auto!important;margin:0 20px 10px!important}#cookieNoticeInner #cookieNoticeTitle{font-size:12px!important;line-height:1.1!important}#cookieNoticeInner #cookieNoticeSubTitle{font-size:10px!important;line-height:1.1!important}#cookieNoticeInner #cookieNoticeSubTitle a{font-size:10px!important}}</style>').appendTo('head');
			
    	}
	});

})(jQuery);
